package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.result.R;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/16 21:43
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;
    @ApiOperation("医院分页列表")
    @PostMapping("/{page}/{limit}")
    public R index(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit,@RequestBody(required = false) HospitalQueryVo hospitalQueryVo){
        Page<Hospital> page1 =hospitalService.selectPage(page, limit, hospitalQueryVo);
        return R.ok().data("items", page1.getContent()).data("total", page1.getTotalElements());
    }
    @PutMapping("/{id}/{status}")
    public R changeStatus(@PathVariable("id") String id, @PathVariable("status") Integer status){
        hospitalService.changeStatus(id, status);
        return R.ok();
    }
    @GetMapping("/detail/{id}")
    public R detail(@PathVariable("id") String id){
        Hospital hospital = hospitalService.selectById(id);
        return R.ok().data("hospital", hospital);
    }


}
